package com.lollipop.synthential;

import org.springframework.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author: J.K
 * @Date: 2021-06-15 10:14
 * @Description:
 */
public class Test {
    public static void main(String[] args) {
//        String str = "1115,1093,1087,1101,1086,1099,1118,1110,1086,1096,1092,1107,1108,1111,1098,1113,1119,1089,1108,1088,1087,1099,1119,1090,1117,1112,1109,1113,1098,1092,1118,1091,1100,1095,1089,1102,1124,1104,1097,1107,1114,1085,1116,1103,1093,1105,1094,1091,1125,1085,1124,1106,1110,1115,1112,1117,1111,1095,1103,1100,1104,1096,1105,1101,1106,1088,1109,1090,1125,1094,1097,1114,1116";
//        String[] arry = str.split(",");
//        List<String> list = Arrays.asList(arry);
//        long count = list.stream().distinct().count();
//        String collect = list.stream().distinct().collect(Collectors.joining(","));
//        System.out.println(count);
//        System.out.println(collect);

//        List<Map<String,Object>> list = new ArrayList<>();
//        IntStream.range(1,5).forEach(e->{
//            Map<String,Object> map = new HashMap<>();
//            map.put("name","张三"+(e<3?e:e-1));
//            map.put("score", (int)(Math.random()*100)+1);
//            list.add(map);
//        });
//        System.out.println(list);
//
//
//        List<Map<String, Object>> sortList = list.stream().sorted((v1, v2) -> {
//            BigInteger b1 = new BigInteger(v1.get("score").toString());
//            BigInteger b2 = new BigInteger(v2.get("score").toString());
//            return b1.compareTo(b2);
//        }).collect(Collectors.toList());
//        System.out.println(sortList);

        String val1 = "1.0034E7";
        String val2 = "19990";
        float v1 = Float.parseFloat(val1);
        float v2 = Float.parseFloat(val2);
        System.out.println(v1 - v2);

        isNumeric(val2);
    }

    public static boolean isNumeric(String str) {
        if (null == str || "".equals(str)) {
            return false;
        }
        String regx = "[+-]*\\d+\\.?\\d*[Ee]*[+-]*\\d+";
        Pattern pattern = Pattern.compile(regx);
        boolean isNumber = pattern.matcher(str).matches();
        if (isNumber) {
            return isNumber;
        }
        regx = "^[-\\+]?[.\\d]*$";
        pattern = Pattern.compile(regx);
        return pattern.matcher(str).matches();
    }

    public static Boolean isNumerics(String str) {
        String reg = "^-?\\d+(\\.\\d+)?$";
        Pattern pattern = Pattern.compile(reg);
        if (StringUtils.hasLength(str)) {
            Matcher matcher = pattern.matcher(str);
            return matcher.matches();
        } else {
            return false;
        }

    }
}
